package frame;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame; 
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import logic.ManagementSystem;

public class MainFrame extends JFrame implements ActionListener {
	
	private JList flatsList;
	
	ManagementSystem managementSystem = ManagementSystem.getInstance();
	
	
	public MainFrame() throws Exception{
		
		// Set layout for all client's form
		getContentPane().setLayout(new BorderLayout());
		
		// Create Bar menu
		JMenuBar menuBar = new JMenuBar();
		
        // Create a drop-down menu
        JMenu menu = new JMenu("Hello");
        
        // Create an item in the drop-down menu
        JMenuItem menuItem = new JMenuItem("World !!!");
        menuItem.setName("helloWorld");
        
        // Add listener for "helloWorld"
        menuItem.addActionListener(this);
        
        // Add item in the drop-down menu
        menu.add(menuItem);
        
        // Add drop-menu to Bar menu
        menuBar.add(menu);
        
        // Set menu for the form
        setJMenuBar(menuBar);
        
		
        // Bounds form
        setBounds(100, 100, 700, 500);
        
        // diminsion for min Bound
        Dimension dimensionMinSizeForm = new Dimension();
        dimensionMinSizeForm.setSize(400, 300);
        
        // set min size Bound
        setMinimumSize(dimensionMinSizeForm);
		
	}


    // Method from interface ActionListener
	@Override
    public void actionPerformed(ActionEvent actionEvent) {
        if (actionEvent.getSource() instanceof Component) {
            Component component = (Component) actionEvent.getSource();
            if (component.getName().equals("helloWorld")) {
                doSomething();
            }
        }
    }
	

	
	//method for action
    private void doSomething() {
        JOptionPane.showMessageDialog(this, "helloWorld");
    }

    
    
    
    public static void main(String args[]) {
        SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                try {
                	MainFrame sf = new MainFrame();
                    sf.setDefaultCloseOperation(EXIT_ON_CLOSE);
                    sf.setVisible(true);

                } catch (Exception ex) {
                    ex.printStackTrace();
                }

            }
        });
    }
    
}
